package com.ylx.controller;

import com.ylx.mapper.PxxGoodsMapper;
import com.ylx.model.common.dtos.ResponseResult;

import com.ylx.model.goods.dtos.GoodsPageReqDto;
import com.ylx.model.goods.pojo.PxxGoods;
import com.ylx.service.PxxGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "GoodsController-商家商品管理")
@RestController
@RequestMapping("/api/img")
@Slf4j
public class GoodsController {
    @Resource
    PxxGoodsService goodsService;

    @GetMapping("/list")
    @ApiOperation("商品列表")
    public ResponseResult list(@RequestBody GoodsPageReqDto dto){
        return goodsService.goodslist(dto);
    }
    @PostMapping("add")
    @ApiOperation("新增商品")
    public ResponseResult add(@RequestBody PxxGoods pxxGoods){
        return goodsService.goodsAdd(pxxGoods);
    }
    @PostMapping("update")
    @ApiOperation("修改商品")
    public ResponseResult update(@RequestBody PxxGoods pxxGoods){
        return goodsService.goodsUpdate(pxxGoods);
    }
    @DeleteMapping("del")
    @ApiOperation("删除商品")
    public ResponseResult del(@PathVariable("id") int id){
        return goodsService.goodsDel(id);
    }
}
